chrome.runtime.onInstalled.addListener(function () {
    // 需要 manifest.json 中增加 storage 权限
    chrome.storage.sync.set({
        color: '#3aa757'
    }, function () {
        console.log("The color is green.");
    });
});

// 需要 manifest.json 中增加 storage 权限
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
    chrome.declarativeContent.onPageChanged.addRules([{
        // 只有 域名 匹配时按钮才可用
        conditions: [new chrome.declarativeContent.PageStateMatcher({
            pageUrl: {
                hostEquals: 'developer.chrome.com'
            },
        })],
        actions: [new chrome.declarativeContent.ShowPageAction()]
    }]);
});
